var bearcat = require("bearcat")
var httpConf = require("../../../../http/httpModule.js")
var areaHandler = function(app) {
  this.app = app;
  this.sessionService = this.app.get('sessionService')
  this.area = this.app.get("area")
};
//获取数据
areaHandler.prototype.getPlayerInfo = function(msg,session,next) {
  var uid = session.uid
  this.accountDao.getPlayerInfo(uid,function(flag,data) {
    next(null,{flag:flag,data:data})
  })
}
//解锁地块
areaHandler.prototype.unlockGrid = function(msg,session,next) {
  var uid = session.uid
  var gridId = msg.gridId
  this.area.unlockGrid(uid,gridId,function(flag,data) {
    next(null,{flag:flag,data:data})
  })
}
//解锁建筑
areaHandler.prototype.unlockBuild = function(msg,session,next) {
  var uid = session.uid
  var buildId = msg.buildId
  this.area.unlockBuild(uid,buildId,function(flag,data) {
    next(null,{flag:flag,data:data})
  })
}
//放置建筑
areaHandler.prototype.placeBuild = function(msg,session,next) {
  var uid = session.uid
  var gridId = msg.gridId
  var buildId = msg.buildId
  this.area.placeBuild(uid,gridId,buildId,function(flag,data) {
    next(null,{flag:flag,data:data})
  })
}
//升级建筑
areaHandler.prototype.upgradeBuild = function(msg,session,next) {
  var uid = session.uid
  var buildId = msg.buildId
  this.area.upgradeBuild(uid,buildId,function(flag,data) {
    next(null,{flag:flag,data:data})
  })
}
//提取收益
areaHandler.prototype.gainBuildAward = function(msg,session,next) {
  var uid = session.uid
  var gridId = msg.gridId
  this.area.gainBuildAward(uid,gridId,function(flag,data) {
    next(null,{flag:flag,data:data})
  })
}
//获取排行榜
areaHandler.prototype.getAssetsRank = function(msg,session,next) {
  var uid = session.uid
  this.area.getAssetsRank(uid,function(flag,data) {
    next(null,{flag:flag,data:data})
  })
}
//领取填字游戏奖励
areaHandler.prototype.gainCrosswordAward = function(msg,session,next) {
  var uid = session.uid
  this.area.gainCrosswordAward(uid,function(flag,data) {
    next(null,{flag:flag,data:data})
  })
}
//获取船只货物
areaHandler.prototype.getShipCargo = function(msg,session,next) {
  var uid = session.uid
  this.area.getShipCargo(uid,function(flag,data) {
    next(null,{flag:flag,data:data})
  })
}
//领取船只货物奖励
areaHandler.prototype.gainShipAward = function(msg,session,next) {
  var uid = session.uid
  var shipId = msg.shipId
  this.area.gainShipAward(uid,shipId,function(flag,data) {
    next(null,{flag:flag,data:data})
  })
}
module.exports = function(app) {
  return bearcat.getBean({
  	id : "areaHandler",
  	func : areaHandler,
  	args : [{
  		name : "app",
  		value : app
  	}],
  	props : [{
  		name : "redisDao",
  		ref : "redisDao"
  	},{
  		name : "accountDao",
  		ref : "accountDao"
  	}]
  })
};